package test.db.table.mysql.type;

import test.db.table.Table;
import test.db.util.DBUtil;

/**
 * @author newbie
 * @since 0.1
 */
public enum PwAuthorityTable implements Table, ColumnType {
    SID(Column.sid),
    AUTHORITY(Column.authority),
    USER_SID(Column.userSid);
    
    private final Column column;
    private static final String TYPE_AUTHORITY = "VARCHAR(64)";

    PwAuthorityTable(Column column) {
        this.column = column;
    }
    
    private enum Column {
        sid {
            String getType() {
                return TYPE_SID;
            }
        },
        
        authority {
            String getType() {
                return TYPE_AUTHORITY;
            }
        },
        
        userSid {
            String getType() {
                return TYPE_USER_SID;
            }
        };
        
        abstract String getType();
    }
    
    public String getType() {
        return column.getType();
    }
    
    public void initData() throws Exception {
        DBUtil.addData("INSERT INTO PW_AUTHORITY VALUES (100000000000000000, 'ROLE_SUPER_USER', 100000000000000000)");
        DBUtil.addData("INSERT INTO PW_AUTHORITY VALUES (200912121212111111, 'ROLE_SUPER_USER', 200912121212111111)");
        DBUtil.addData("INSERT INTO PW_AUTHORITY VALUES (200912121212111113, 'ROLE_USER', 200912121212111111)");
        DBUtil.addData("INSERT INTO PW_AUTHORITY VALUES (200912121212111114, 'ROLE_USER_READ', 200912121212111111)");
        DBUtil.addData("INSERT INTO PW_AUTHORITY VALUES (200912121212111112, 'ROLE_USER', 200912121212111112)");
    }
}